package blackhouse_server;

import java.sql.SQLException;
import java.util.List;

import blackhouse_dao.subject_dao;
import blackhouse_entity.subject;

public class gradesub_server
{
	subject_dao	sd	= new subject_dao();

	public List<subject> show_subject() throws SQLException
	{
		String sql = "SELECT a.id,a.subjectCode,a.subjectName,a.teacherName,a.createTime,c.gradeName FROM SUBJECT a LEFT JOIN tclass b ON a.`Id` = b.`subid` LEFT JOIN grade c ON a.gradeID = c.`id`;";
		return sd.show_subgrade(sql);
	}

	public boolean delsubject(int key)
	{
		String sql = "DELETE FROM SUBJECT WHERE id = " + key;
		if (sd.delsubject(sql))
		{
			sql = "DELETE FROM tclass WHERE subid=" + key;
		}
		return sd.delsubject(sql);
	}
}
